package ReefStats::Schema::ReefStatsDB::Roles;

use warnings;
use strict;
use base 'DBIx::Class';
use ReefStats::Schema::DataTypes;

__PACKAGE__->load_components(qw/Core/);
__PACKAGE__->table('roles_');
__PACKAGE__->add_columns(
    id   => { @_int_id, },
    role => { @_varchar_255, @_not_null, },
);
__PACKAGE__->set_primary_key('id');
__PACKAGE__->add_unique_constraint( ['role'] );

__PACKAGE__->has_many(
    map_user_role => 'ReefStats::Schema::ReefStatsDB::UserRoles',
    => 'role_id'
);

__PACKAGE__->many_to_many(
    'users' => 'map_user_role',
    'email_address',
    { cascade_delete => 0 },
);

1;

__END__
